package com.jay.loglibrary;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import androidx.annotation.NonNull;

/**
 * @ClassName: HiLogManager
 * @Description: Log管理
 * @Author: yangjie
 * @Date: 2022/4/3 7:13 下午
 */
public class HiLogManager {
    private HiLogConfig config;

    private  static HiLogManager instance;

    private List<HiLogPrinter> printers=new ArrayList<>();

    private HiLogManager(HiLogConfig config,HiLogPrinter[] printers){
        this.config=config;
        this.printers.addAll(Arrays.asList(printers));
    }

    private  HiLogManager(HiLogConfig config){
        this.config=config;
    }

    public static HiLogManager getInstance(){
        return instance;
    }

    public static  void init(@NonNull HiLogConfig config){
        instance = new HiLogManager(config);
    }

    public  HiLogConfig getConfig(){
        return config;
    }

    public  static  void init(@NonNull HiLogConfig config,HiLogPrinter... printers){
        instance=new HiLogManager(config,printers);
    }

    public List<HiLogPrinter> getPrinters(){
        return  printers;
    }

    public  void addPrinter(HiLogPrinter printer){
        printers.add(printer);
    }

    public void  removePrinter(HiLogPrinter printer){
        if(printers!=null){
            printers.remove(printer);
        }
    }

}
